#!/usr/bin/env python
# -*- coding:utf8 -*-
from db import db_handler
from lib import common

admin_logger = common.get_logger('admin')


# 修改额度接口
def changer_balance_interface(username, money):
    user_dic = db_handler.select(username)
    if user_dic:
        user_dic['balance'] = int(money)

        db_handler.save(user_dic)
        msg = "额度修改成功"
        admin_logger.info(msg)
        return True, msg
    msg = '修改额度用户不存在'
    admin_logger.error(msg)
    return False, msg


# 冻结账户
def lock_user_interface(username):
    user_dic = db_handler.select(username)
    if user_dic:
        user_dic['locked'] = True

        db_handler.save(user_dic)

        return True, f'用户{username}冻结成功！'
    return False, '冻结用户不存在'
